package com.yk.neon.lib.util.mybatis.converter;

import org.dozer.CustomConverter;

public class Integer2BooleanConverter implements CustomConverter {

	@Override
	public Object convert(Object destination, Object source, Class<?> destinationClass, Class<?> sourceClass) {
		if (null == source) {
			return null;
		}
		if (source instanceof Boolean) {
			if ((Boolean) source) {
				return 1;
			} else {
				return 0;
			}
		} else if (source instanceof Integer) {
			if (1 == (Integer) source) {
				return true;
			} else {
				return false;
			}
		}
		return null;
	}
}
